<template>
	<view>
		<!-- 我的发布 -->
		<view class="bg-white p-2" style="width: 2000rpx;">
			<view v-if="select==0" class="">
				<view class="flex font-md align-center">
					<view @click="selectActive(index)" class="p-2 px-4" :class="active==index?'active':''"
						v-for="(item,index) in navData" :key="index">
						<text>{{item.name}}</text>
						<text>({{item.value}})</text>
					</view>
				</view>
				<view class="p-2 flex flex-column" style="background-color: rgb(249,249,249);flex-wrap: wrap;">
					<view class="flex mb-3">
						<view class="flex align-center  mr-4">
							<text>商品名称:</text>
							<view class="ml-2">
								<uni-easyinput v-model.trim="form.Article_Name" placeholder="请输入商品名称"></uni-easyinput>
							</view>
						</view>
						<view class="flex align-center mr-4">
							<text>专场:</text>
							<view class="ml-2">
								<uni-easyinput></uni-easyinput>
							</view>
						</view>
						<view class="flex align-center mr-4">
							<text>类型:</text>
							<view class="ml-2">
								<uni-data-select empty-text="暂无发票单号" placeholder="请选择类型" v-model="Selectvalue"
									:localdata="range" @change="change"></uni-data-select>
							</view>
						</view>
						<view class="flex-1">

						</view>
						<view class="">
							<view @click="Inquire()" class="text-white bg-orange px-4 py-2 text-center"
								style="border-radius: 10rpx;cursor: pointer;">
								<text>查询</text>
							</view>
						</view>
					</view>
					<view class="flex">
						<view class="flex align-center mr-4">
							<view class="ml-2">
								<uni-badge class="uni-badge-left-margin" :text="value" absolute="rightTop" size="small">
									<button @click="show(form2)" class="uni-button" size="mini"
										type="primary">我的交易</button>
								</uni-badge>
							</view>
						</view>
						<view class="flex align-center">
							<view class="ml-2">
								<button @click="posting()" class="uni-button" size="mini" type="primary">发布</button>
							</view>
						</view>
						<view class="flex align-center">
							<view class="ml-2">
								<uni-badge class="uni-badge-left-margin" :text="value" absolute="rightTop" size="small">
									<button @click="goMessage()" class="uni-button" size="mini" style="background-color: #eee;" type="info">消息</button>
								</uni-badge>
							</view>
						</view>
						<view class="flex-1">

						</view>
						<view class="">
							<view @click="reset()" class="text-white bg-orange px-4 py-2 text-center"
								style="border-radius: 10rpx;cursor: pointer;">
								<text>重置</text>
							</view>
						</view>
					</view>
				</view>
				<view class="">
					<!-- 表格 -->
					<uni-table border :loading="loading" stripe emptyText="暂无更多数据">
						<!-- 表头行 -->
						<uni-tr>
							<uni-th width="60" align="center">序号</uni-th>
							<uni-th width="80" align="center">商品图片</uni-th>
							<uni-th width="80" align="center">商品编号</uni-th>
							<uni-th width="78" align="center">商品名称</uni-th>
							<uni-th width="50" align="center">总数量</uni-th>
							<uni-th width="50" align="center">价格</uni-th>
							<uni-th width="95" align="center">起步购买量</uni-th>
							<uni-th width="80" align="center">销售量</uni-th>
							<uni-th width="70" align="center">剩余量</uni-th>
							<uni-th width="75" align="center">联系人</uni-th>
							<uni-th width="100" align="center">操作</uni-th>
						</uni-tr>
						<!-- 表格数据行 -->
						<uni-tr v-for="(item,i) in MessageData" :key="i">
							<uni-td align="center">{{i+1}}</uni-td>
							<uni-td align="center">
								<image style="width: 100rpx;height: 100rpx;border-radius: 10rpx;"
									:src="Domain_IMG + item.Picture_URL">
								</image>
							</uni-td>
							<uni-td align="center">{{item.Group_Purchasing_SerialNumber}}</uni-td>
							<uni-td align="center">
								<view :title="item.Article_Name" style="width: 110rpx;"
									class="text-ellipsis text-center">
									<text>{{item.Article_Name}}</text>
								</view>
							</uni-td>
							<uni-td align="center">{{item.Total_Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
							<uni-td align="center">￥{{item.Amount}}</uni-td>
							<uni-td align="center">{{item.Starting_Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
							<uni-td align="center">{{item.Sell_Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
							<uni-td align="center">{{item.Residue_Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
							<uni-td align="center">{{item.Contacts}}</uni-td>
							<uni-td align="center">
								<button @click="getDataDetail(item.Group_Purchasing_SerialNumber)" class="uni-button"
									size="mini" type="primary">查看</button>
							</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view v-if="MessageData.length>0" class="py-2 pr-2" style="background-color: rgb(248,249,250);">
					<view class="flex align-center justify-end">
						<text class="mx-2">共{{total}}页</text>
						<view class="flex align-center">
							<button @click="previousPage" :disabled="active3==0" style="width: 10px; height: 30px;"
								class="flex align-center justify-center">
								<uni-icons :color="(active3==0?'gray':'black')" type="left"></uni-icons>
							</button>
							<text :class="(active3==index?'getPages':'bgc')+' mx-2 text-center' "
								@click="getPages(index)" style=" line-height: 30px; width: 30px; height: 30px;"
								v-for="(item,index) in total" :key="index">{{index+1}}</text>
							<button @click="nextPage" :disabled="active3==total-1" style="width: 10px; height: 30px;"
								class="flex align-center justify-center">
								<uni-icons :color="(active3==total-1?'gray':'black')" type="right"></uni-icons>
							</button>
						</view>
						<view class="ml-3 flex align-center justify-center">
							<text>前往</text>
							<input class="border rounded text-center mx-2" style="width: 40px;" type="number"
								@keydown.enter="enter" v-model.number="active4">
							<text>页</text>
						</view>
					</view>
				</view>
			</view>
			<view v-if="select==1" class="">
				<view class="">
					<Navtitle title="标品信息"></Navtitle>
					<view class="flex py-2 align-center justify-center">
						<image v-if="MessageDetailData.Picture_URL!= void 0" style="height: 550rpx;"
							:src="Domain_IMG + MessageDetailData.Picture_URL" mode="heightFix"></image>
						<view class="flex flex-column" style="flex-wrap: wrap;height: 550rpx;">
							<uni-list-item class="mr-5" title="商品名称" :rightText="MessageDetailData.Article_Name" />
							<uni-list-item title="挂单标题" :rightText="''" />
							<uni-list-item title="保证方式" :rightText="MessageDetailData.Guarantee_Method" />
							<uni-list-item title="类别" :rightText="MessageDetailData.Category_Name" />
							<uni-list-item title="商品价格" :rightText="MessageDetailData.Amount" />
							<uni-list-item title="商品总量" :rightText="MessageDetailData.Total_Quantity" />
							<uni-list-item title="联系人" :rightText="MessageDetailData.Contacts" />
							<uni-list-item title="联系人手机号" :rightText="MessageDetailData.Contacts_Phone" />
							<uni-list-item title="卖家企业" :rightText="MessageDetailData.Enterprise_Name" />
							<uni-list-item title="预定交货时间" :rightText="MessageDetailData.Delivery_Time" />
							<uni-list-item title="起步价" :rightText="MessageDetailData.Starting_Quantity" />
						</view>
					</view>
				</view>
				<view class="">
					<Navtitle title="交易记录"></Navtitle>
					<view class="py-2">
						<uni-table border :loading="loading" stripe emptyText="暂无更多数据">
							<!-- 表头行 -->
							<uni-tr>
								<uni-th width="60" align="center">序号</uni-th>
								<uni-th width="60" align="center">商品编号</uni-th>
								<uni-th width="78" align="center">商品名称</uni-th>
								<uni-th width="50" align="center">总数量</uni-th>
								<uni-th width="80" align="center">购买数量</uni-th>
								<uni-th width="50" align="center">花费</uni-th>
								<uni-th width="95" align="center">买家联系人</uni-th>
								<uni-th width="80" align="center">买家手机号</uni-th>
								<uni-th width="70" align="center">状态</uni-th>
								<uni-th width="75" align="center">卖家企业</uni-th>
								<uni-th width="120" align="center">交易完成时间</uni-th>
							</uni-tr>
							<!-- 表格数据行 -->
							<uni-tr v-for="(item,i) in TransactionhistoryData" :key="i">
								<uni-td align="center">{{i+1}}</uni-td>
								<uni-td align="center">{{item.Group_Transaction_SerialNumber}}</uni-td>
								<uni-td align="center">
									<view :title="item.Article_Name" style="width: 110rpx;"
										class="text-ellipsis text-center">
										<text>{{item.Article_Name}}</text>
									</view>
								</uni-td>
								<uni-td
									align="center">{{item.Total_Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
								<uni-td align="center">{{item.Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
								<uni-td align="center">￥{{item.Amount}}</uni-td>
								<uni-td align="center">{{item.Contacts}}</uni-td>
								<uni-td align="center">{{item.Contacts_Phone}}</uni-td>
								<uni-td align="center">{{item.Buyer_Status}}</uni-td>
								<uni-td align="center">
									<view :title="item.Enterprise_Name" style="width: 110rpx;"
										class="text-ellipsis text-center">
										<text>{{item.Enterprise_Name}}</text>
									</view>
								</uni-td>
								<uni-td align="center">{{item.Submission_Time}}</uni-td>
							</uni-tr>
						</uni-table>
					</view>
					<view v-if="TransactionhistoryData.length>0" class="p-2 justify-between flex align-center"
						style="background-color: rgb(248,249,250);">
						<view class="flex align-center">
							<button @click="back()" class="uni-button" size="mini" type="primary">返回上一页</button>
						</view>
						<view class="flex align-center">
							<text class="mx-2">共{{total}}页</text>
							<view class="flex align-center">
								<button @click="previousPage" :disabled="active3==0" style="width: 10px; height: 30px;"
									class="flex align-center justify-center">
									<uni-icons :color="(active3==0?'gray':'black')" type="left"></uni-icons>
								</button>
								<text :class="(active3==index?'getPages':'bgc')+' mx-2 text-center' "
									@click="getPages(index)" style=" line-height: 30px; width: 30px; height: 30px;"
									v-for="(item,index) in total" :key="index">{{index+1}}</text>
								<button @click="nextPage" :disabled="active3==total-1"
									style="width: 10px; height: 30px;" class="flex align-center justify-center">
									<uni-icons :color="(active3==total-1?'gray':'black')" type="right"></uni-icons>
								</button>
							</view>
							<view class="ml-3 flex align-center justify-center">
								<text>前往</text>
								<input class="border rounded text-center mx-2" style="width: 40px;" type="number"
									@keydown.enter="enter" v-model.number="active4">
								<text>页</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="select==2" class="">
				<view class="">
					<view class="py-2">
						<uni-table border :loading="loading" stripe emptyText="暂无更多数据">
							<!-- 表头行 -->
							<uni-tr>
								<uni-th width="80" align="center">序号</uni-th>
								<uni-th width="60" align="center">商品图</uni-th>
								<uni-th width="90" align="center">商品名称</uni-th>
								<uni-th width="70" align="center">总数量</uni-th>
								<uni-th width="150" align="center">起步购买量</uni-th>
								<uni-th width="50" align="center">价格</uni-th>
								<uni-th width="95" align="center">所属企业</uni-th>
								<uni-th width="120" align="center">联系人</uni-th>
								<uni-th align="center">联系人电话</uni-th>
								<uni-th align="center">装货方式</uni-th>
								<uni-th align="center">支付方式</uni-th>
								<uni-th align="center">物流方式</uni-th>
								<uni-th align="center">状态</uni-th>
								<uni-th align="center">发布时间</uni-th>
								<uni-th align="center">支付阶段</uni-th>
								<uni-th width="150" align="center">操作</uni-th>
							</uni-tr>
							<!-- 表格数据行 -->
							<uni-tr v-for="(item,i) in MyPurchasesData" :key="i">
								<uni-td align="center">{{i+1}}</uni-td>
								<uni-td align="center">
									<image style="width: 100rpx;height: 100rpx;border-radius: 10rpx;"
										:src="Domain_IMG + item.Picture_URL">
									</image>
								</uni-td>
								<uni-td align="center">
									<view :title="item.Article_Name" style="width: 110rpx;"
										class="text-ellipsis text-center">
										<text>{{item.Article_Name}}</text>
									</view>
								</uni-td>
								<uni-td
									align="center">{{item.Total_Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
								<uni-td align="center">{{item.Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
								<uni-td align="center">￥{{item.Amount}}</uni-td>
								<uni-td align="center">
									<view :title="item.Enterprise_Name" style="width: 110rpx;"
										class="text-ellipsis text-center">
										<text>{{item.Enterprise_Name}}</text>
									</view>
								</uni-td>
								<uni-td align="center">{{item.Buyer_Contact}}</uni-td>
								<uni-td align="center">{{item.Buyer_Contact_Phone}}</uni-td>
								<uni-td align="center">{{item.Shipment_Type}}</uni-td>
								<uni-td align="center">{{item.Trading_Type=='0'?'全款':'按阶段付款'}}</uni-td>
								<uni-td align="center">{{item.Transport_Type}}</uni-td>
								<uni-td align="center">
									<text v-if="item.Row_Status=='0'">待审核</text>
									<text v-if="item.Row_Status=='1'">待确认合同</text>
									<text v-if="item.Row_Status=='4'&&item.Buyer_Status=='0'">待对方确认</text>
									<text
										v-if="item.Row_Status=='4'&&item.Buyer_Status=='4'&&item.Paystages.split('/')[0]=='0'">待对方付定金</text>
									<text
										v-if="item.Row_Status=='4'&&item.Buyer_Status=='4'&&item.Paystages.split('/')[0]=='1'">待发货</text>
									<text v-if="item.Row_Status=='5'">待对方收货</text>
									<text v-if="item.Row_Status=='6'&&item.Pay_Status=='0'">待对方付尾款</text>
									<text v-if="item.Row_Status=='6'&&item.Pay_Status=='1'">交易结束</text>
								</uni-td>
								<uni-td align="center">{{item.Submission_Time}}</uni-td>
								<uni-td align="center">
									<view
										:style="item_ != '0'?'background-color: rgb(0, 200, 200);':'background-color: rgb(200, 54, 56);'"
										style="color: #fff;border-radius: 10rpx; display: inline-block; margin-left:10rpx;"
										class="p-2 mr-2" v-for="(item_,index_) in item.Collection_Amount.split('/')"
										:key="index_">{{item_!='0'?`已付款${item_}`:`第${index_+1}笔未付`}}</view>
								</uni-td>
								<uni-td align="center">
									<view class="flex">
										<button :disabled="disabled" @click="Inventory(item)"
											v-if="item.Row_Status == '0'"
											style="width: 150rpx;height: 80rpx;flex align-items: center;line-height: 80rpx;"
											class="uni-button mr-2" size="mini" type="success">通过</button>
										<button :disabled="disabled"
											@click="getDetail(item.Group_Transaction_SerialNumber)"
											v-if="item.Row_Status == '1'"
											style="width: 180rpx;height: 80rpx;flex align-items: center;line-height: 80rpx;"
											class="uni-button" size="mini" type="warn">确认合同</button>
										<button :disabled="disabled" @click="toggle('center',item)"
											v-if="item.Row_Status == '4'&&item.Buyer_Status == '4'&&item.Paystages.split('/')[0]=='1'"
											style="width: 150rpx;height: 80rpx;flex align-items: center;line-height: 80rpx;"
											class="uni-button" size="mini" type="warn">发货</button>
										<button :disabled="disabled" @click="RefuseProcurement(item)"
											v-if="item.Row_Status == '0'"
											style="width: 150rpx;height: 80rpx;flex align-items: center;line-height: 80rpx;"
											class="uni-button" size="mini" type="warn">拒绝</button>
									</view>
								</uni-td>
							</uni-tr>
						</uni-table>
					</view>
					<view class="">
						<uni-popup ref="popup" background-color="#fff" @change="change">
							<view class="popup-content flex-column align-center">
								<view class="flex mb-2 justify-center align-center">
									物流信息:<uni-easyinput v-model="Explain" placeholder="请输入发货信息如:物流单号" />
								</view>
								<button @click="Consignment()" size="mini" type="primary"
									class="uni-button">点我发货</button>
							</view>
						</uni-popup>
					</view>
					<view v-if="MyPurchasesData.length>0" class="p-2 justify-between flex align-center"
						style="background-color: rgb(248,249,250);">
						<view class="flex align-center">
							<button @click="back()" class="uni-button" size="mini" type="primary">返回上一页</button>
						</view>
						<view class="flex align-center">
							<text class="mx-2">共{{total}}页</text>
							<view class="flex align-center">
								<button @click="previousPage" :disabled="active3==0" style="width: 10px; height: 30px;"
									class="flex align-center justify-center">
									<uni-icons :color="(active3==0?'gray':'black')" type="left"></uni-icons>
								</button>
								<text :class="(active3==index?'getPages':'bgc')+' mx-2 text-center' "
									@click="getPages(index)" style=" line-height: 30px; width: 30px; height: 30px;"
									v-for="(item,index) in total" :key="index">{{index+1}}</text>
								<button @click="nextPage" :disabled="active3==total-1"
									style="width: 10px; height: 30px;" class="flex align-center justify-center">
									<uni-icons :color="(active3==total-1?'gray':'black')" type="right"></uni-icons>
								</button>
							</view>
							<view class="ml-3 flex align-center justify-center">
								<text>前往</text>
								<input class="border rounded text-center mx-2" style="width: 40px;" type="number"
									@keydown.enter="enter" v-model.number="active4">
								<text>页</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<Notify :show="LetterCommitment" :content="message" :type="type"></Notify>
	</view>
</template>

<script>
	import Notify from '@/components/Notify/Notify.vue'
	import Navtitle from '@/components/Navtitle/Navtitle.vue'
	import times from '@/mixins/time.js'
	const app = getApp()
	export default {
		name: "MyPosting",
		data() {
			return {
				form: {
					Article_Name: "",
					Category_SerialNumber: "",
					Enterprise_Info_SerialNumber: "",
					Type: "1",
					token: "",
					page: 1, //页数
					limit: 5, //每页数据条数
				},
				disabled: false,
				form1: {
					Article_Name: "",
					Category_SerialNumber: "",
					Enterprise_Info_SerialNumber: "",
					Type: "0",
					Group_Purchasing_SerialNumber: '',
					token: "",
					page: 1, //页数
					limit: 5, //每页数据条数
				},
				form2: {
					Type: "1",
					Group_Purchasing_SerialNumber: '',
					token: "",
					Enterprise_Info_SerialNumber: "",
					page: 1, //页数
					limit: 5, //每页数据条数
				},
				select: 0,
				Domain_IMG: app.globalData.Domain_IMG,
				loading: true,
				LetterCommitment: false,
				type: 'info',
				message: '',
				value: 2,
				payStage: '0/0/0',
				limit: 0,
				total: 0,
				active3: 0, // 分页器换颜色
				active4: 0,
				types: 'center',
				MessageData: [],
				MessageDetailData: {},
				TransactionhistoryData: [],
				MyPurchasesData: [],
				datetimerange: [],
				group_transaction_logistics: {
					Group_Logistics_SerialNumber: '', //主键
					Group_Transaction_SerialNumber: '', //交易流水号
					Transport_Type: '', //运输方式
					Transport_Explain: '' //说明
				},
				formData: {
					Group_Transaction_SerialNumber: "", //主键
					Group_Purchasing_SerialNumber: "", //流水号
					Quantity: "", //总量
					Amount: "", //钱
					Submission_Time: "", //时间
					Trading_Type: "",
					Group_Purchasing_Payment_SerialNumber: "",
					Group_Purchasing_Shipment_SerialNumber: "",
					Group_Purchasing_Transport_SerialNumber: "",
					Buyer_Contact: "", //买主姓名
					Buyer_Contact_Phone: "", //买主手机号
					Buyer_Enterprise_Info_SerialNumber: "", //买主公司编号
					Enterprise_Info_SerialNumber: "", //卖家公司编号
				},
				OddNumbers: false,
				range: [{
						value: 0,
						text: "全部"
					},
					{
						value: 1,
						text: "采购"
					},
					{
						value: 2,
						text: "销售"
					},
				],
				range1: [{
						value: 0,
						text: "全部"
					},
					{
						value: 1,
						text: "待交易"
					},
					{
						value: 2,
						text: "交易中"
					},
					{
						value: 3,
						text: "已成交"
					},
					{
						value: 4,
						text: "未成交"
					},
				],
				Selectvalue: '',
				Explain: "",
				active: 0,
				navData: [{
						name: '全部',
						value: 0
					},
					{
						name: '待审核',
						value: 0
					},
					{
						name: '审核通过',
						value: 0
					},
					{
						name: '已驳回',
						value: 0
					},
					{
						name: '待提交',
						value: 0
					},
				]
			};
		},
		components: {
			Notify,
			Navtitle
		},
		methods: {
			selectActive(index) {
				this.active = index
			},
			getData(data) {
				uni.request({ //获取所有招标信息
					url: app.globalData.Domain_Name + '/getGroupProcureAllAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						this.loading = false
						this.MessageData = res.data.tableData
						console.log(res.data);
						this.limit = res.data.limit
						this.navData[0].value = this.limit
						if (this.limit % this.form.limit != 0) {
							this.total = Math.floor(this.limit / this.form.limit) + 1
						} else {
							this.total = Math.floor(this.limit / this.form.limit)
						}
					}
				})
			},
			getDataDetail(Group_Purchasing_SerialNumber) {
				this.select = 1
				this.active3 = 0
				this.active4 = this.active3 + 1
				this.limit = 0
				this.total = 0
				this.getTransactionhistory(this.form1)
				uni.request({ //获取所有招标信息
					url: app.globalData.Domain_Name + '/getGroupProcureIDAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Purchasing_SerialNumber,
						token: this.form.token,
					},
					success: (res) => {
						this.loading = false
						console.log(res.data)
						this.MessageDetailData = res.data.Data
					}
				})
			},
			getTransactionhistory(data) {
				uni.request({ //获取所有招标信息
					url: app.globalData.Domain_Name + '/getGroupTransactionAllAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						this.loading = false
						console.log(res.data)
						this.TransactionhistoryData = res.data.tableData
						this.limit = res.data.limit
						if (this.limit % this.form1.limit != 0) {
							this.total = Math.floor(this.limit / this.form1.limit) + 1
						} else {
							this.total = Math.floor(this.limit / this.form1.limit)
						}
					}
				})
			},
			change(e) {
				console.log(e)
			},
			getPages(index) {
				if (this.select == 0) {
					if (this.form.page == index + 1) {
						return
					}
					this.active3 = index;
					this.active4 = this.active3 + 1
					this.form.page = index + 1
					this.loading = true
					this.getData(this.form)
				} else if (this.select == 1) {
					if (this.form1.page == index + 1) {
						return
					}
					this.active3 = index;
					this.active4 = this.active3 + 1
					this.form1.page = index + 1
					this.loading = true
					this.getTransactionhistory(this.form1)
				}
			},
			enter(e) {
				//如果输入框的值不为空
				if (this.select == 0) {
					if (e.detail.value != '') {
						//如果输入框的值超过总页数
						if (this.active4 > this.total) {
							//输入框的值强制为总页数
							this.active4 = this.total
						} else if (this.active4 <= 0) { //如果输入框的值为小于0
							//输入框的值强制为1
							this.active4 = 1
						}
						//如果输入框的值为小数则四舍五入转整数
						if (this.active4 > 1) {
							this.active4 = Math.floor(this.active4)
						} else {
							this.active4 = 1
						}
						this.active3 = this.active4 - 1
						//如果输入框的值与当前请求的值相等则不允许发送请求
						if (this.form.page == this.active4) {
							return
						}
						//把处理过后的输入框值赋值给请求
						this.form.page = this.active4
						this.loading = true
						this.getData(this.form)
					}
				} else if (this.select == 1) {
					if (e.detail.value != '') {
						//如果输入框的值超过总页数
						if (this.active4 > this.total) {
							//输入框的值强制为总页数
							this.active4 = this.total
						} else if (this.active4 <= 0) { //如果输入框的值为小于0
							//输入框的值强制为1
							this.active4 = 1
						}
						//如果输入框的值为小数则四舍五入转整数
						if (this.active4 > 1) {
							this.active4 = Math.floor(this.active4)
						} else {
							this.active4 = 1
						}
						this.active3 = this.active4 - 1
						//如果输入框的值与当前请求的值相等则不允许发送请求
						if (this.form1.page == this.active4) {
							return
						}
						//把处理过后的输入框值赋值给请求
						this.form1.page = this.active4
						this.loading = true
						this.getTransactionhistory(this.form1)
					}
				}
			},
			nextPage() {
				if (this.select == 0) {
					this.active3++
					this.active4 = this.active3 + 1
					this.form.page++
					this.loading = true
					this.getData(this.form)
				} else if (this.select == 1) {
					this.active3++
					this.active4 = this.active3 + 1
					this.form1.page++
					this.loading = true
					this.getTransactionhistory(this.form1)
				}
			},
			previousPage() {
				if (this.select == 0) {
					this.active3--
					this.active4 = this.active3 + 1
					this.form.page--
					this.loading = true
					this.getData(this.form)
				} else if (this.select == 1) {
					this.active3--
					this.active4 = this.active3 + 1
					this.form1.page--
					this.loading = true
					this.getTransactionhistory(this.form1)
				}
			},
			Inquire() {
				if (this.form.Article_Name == '') {
					this.LetterCommitment = true
					this.type = 'error'
					this.message = '请输入商品名称再进行查询'
					setTimeout(() => {
						this.LetterCommitment = false
					}, 2000)
					return
				}
				this.loading = true
				this.form.page = 1
				this.getData(this.form)
			},
			reset() {
				this.loading = true
				this.form = {
						Article_Name: "",
						Category_SerialNumber: "",
						Enterprise_Info_SerialNumber: "",
						Type: "1",
						token: "",
						page: 1, //页数
						limit: 5, //每页数据条数
					},
					this.form.token = uni.getStorageSync('token')
				this.form.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
				this.active3 = 0
				this.active4 = this.active3 + 1
				this.total = 1
				this.getData(this.form)
			},
			back() {
				this.select = 0
				this.active3 = 0
				this.active4 = this.active3 + 1
				this.limit = 0
				this.total = 0
				this.form = {
						Article_Name: "",
						Category_SerialNumber: "",
						Enterprise_Info_SerialNumber: "",
						Type: "1",
						token: "",
						page: 1, //页数
						limit: 5, //每页数据条数
					},
					this.form.token = uni.getStorageSync('token')
				this.form.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
				this.getData(this.form)
			},
			show(data) {
				this.loading = true
				this.select = 2
				this.active3 = 0
				this.active4 = this.active3 + 1
				this.limit = 0
				this.total = 0
				uni.request({ //拿到
					url: app.globalData.Domain_Name + '/getGroupTransactionAllAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						this.loading = false
						console.log(res.data)
						this.MyPurchasesData = res.data.tableData
						this.limit = res.data.limit
						if (this.limit % this.form2.limit != 0) {
							this.total = Math.floor(this.limit / this.form2.limit) + 1
						} else {
							this.total = Math.floor(this.limit / this.form2.limit)
						}
					}
				})
			},
			getDetail(Group_Transaction_SerialNumber) {
				this.disabled = true
				var token = uni.getStorageSync('token')
				let _this = this;
				let obj = {
					// 采购信息表
					group_transaction: {
						group_transaction_paystages: {}
					}
				}
				uni.request({
					url: app.globalData.Domain_Name + '/getSubtableInquiryOriginal',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Primary_Key: Group_Transaction_SerialNumber,
						JSONObject: JSON.stringify(obj),
						token,
					},
					success: (res) => {
						this.formData = res.data.group_transaction[0]
						this.ConfirmContract(token)
					}
				})
			},
			ConfirmContract(token) { //确认合同
				var Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
				console.log(this.formData)
				this.formData.Row_Status = '4'
				var group_message_buyer = {
					Group_Message_SerialNumber: "",
					Group_Transaction_SerialNumber: this.formData.Group_Transaction_SerialNumber,
					Cause: "确认合同",
					Submission_Time: times.nowtime(),
					Enterprise_Info_SerialNumber,
					Seller_Type: "0"
				}
				let data = {
					Data: JSON.stringify({
						Modify: {
							group_transaction: [this.formData]
						},
						Add: {
							group_message: [group_message_buyer]
						}
					}),
					token,
				}
				uni.request({
					url: app.globalData.Domain_Name + '/getEditAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						console.log(res.data)
						this.disabled = false
						if (res.data.Status == 'success') {
							this.type = 'success',
								this.message = '已确认合同'
							this.LetterCommitment = true
							this.show(this.form2)
							setTimeout(() => {
								this.LetterCommitment = false
							}, 2000)
						}
					}
				})
			},
			Consignment() { //发货
				this.disabled = true
				var data = uni.getStorageSync('Data')
				var token = uni.getStorageSync('token')
				this.group_transaction_logistics.Transport_Type = data.Transport_Type
				this.group_transaction_logistics.Transport_Explain = this.Explain
				this.group_transaction_logistics.Group_Transaction_SerialNumber = data.Group_Transaction_SerialNumber
				let obj = {
					// 采购信息表
					group_transaction: {
						group_transaction_paystages: {}
					}
				}
				console.log(this.group_transaction_logistics)
				uni.request({
					url: app.globalData.Domain_Name + '/getSubtableInquiryOriginal',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Primary_Key: data.Group_Transaction_SerialNumber,
						JSONObject: JSON.stringify(obj),
						token,
					},
					success: (res) => {
						this.disabled = false
						console.log(res.data)
						this.formData = res.data.group_transaction[0]
						this.Consignments()
					}
				})
			},
			Consignments() {
				this.$refs.popup.close()
				var group_message_buyer = {
					Group_Message_SerialNumber: "",
					Group_Transaction_SerialNumber: this.formData.Group_Transaction_SerialNumber,
					Cause: "已发货",
					Submission_Time: times.nowtime(),
					Enterprise_Info_SerialNumber: "",
					Seller_Type: "0"
				}
				group_message_buyer.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
				this.formData.Row_Status = '5'
				var token = uni.getStorageSync('token')
				let data = {
					Data: JSON.stringify({
						Modify: {
							group_transaction: [this.formData]
						},
						Add: {
							group_transaction_logistics: [this.group_transaction_logistics],
							group_message: [group_message_buyer]
						},
					}),
					token,
				}
				uni.request({
					url: app.globalData.Domain_Name + '/getEditAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						this.disabled = false
						console.log(res.data)
						this.type = 'success'
						this.message = '已发货'
						this.LetterCommitment = true
						setTimeout(() => {
							this.LetterCommitment = false
						}, 2000)
						this.show(this.form2)
					}
				})
			},
			Inventory(data) { //通过
				this.disabled = true
				var token = uni.getStorageSync('token')
				uni.request({
					url: app.globalData.Domain_Name + '/GroupCheckStockAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Purchasing_SerialNumber: data.Group_Purchasing_SerialNumber,
						Quantity: data.Quantity,
						token,
					},
					success: (res) => {
						console.log(res.data)
						this.disabled = false
						if (res.data.Status == 'success') {
							this.AgreePurchase(data, token)
						} else {
							this.LetterCommitment = true
							this.message = '库存不足'
							this.type = 'error'
							setTimeout(() => {
								this.LetterCommitment = false
							}, 2000)
						}
					}
				})
			},
			RefuseProcurement(data) { //拒绝
				this.disabled = true
				var token = uni.getStorageSync('token')
				uni.request({ //获取所有招标信息
					url: app.globalData.Domain_Name + '/GroupTransactionExamineAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Transaction_SerialNumber: data.Group_Transaction_SerialNumber,
						Audit_Status: '2',
						Cause: '拒绝',
						token,
					},
					success: (res) => {
						this.disabled = false
						console.log(res.data)
						if (res.data.Status == "success") {
							this.LetterCommitment = true
							this.message = '已拒绝申请'
							this.type = 'success'
							setTimeout(() => {
								this.LetterCommitment = false
							}, 2000)
							this.show(this.form2)
						}
					}
				})
			},
			AgreePurchase(data, token) {
				this.disabled = true
				uni.request({ //获取所有招标信息
					url: app.globalData.Domain_Name + '/GroupTransactionExamineAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Transaction_SerialNumber: data.Group_Transaction_SerialNumber,
						Audit_Status: '1',
						Cause: '',
						token,
					},
					success: (res) => {
						this.disabled = false
						console.log(res.data)
						if (res.data.Status == "success") {
							this.LetterCommitment = true
							this.message = '已通过'
							this.type = 'success'
							setTimeout(() => {
								this.LetterCommitment = false
							}, 2000)
							this.show(this.form2)
						}
					}
				})
			},
			posting() {
				uni.navigateTo({
					url: '/pages/Posting/TenderPosting'
				})
			},
			goMessage() {
				uni.navigateTo({
					url: '/pages/MyMessage/MyMessage?id=1.1'
				})
			},
			toggle(type, item) {
				uni.setStorageSync('Data', item)
				this.types = type
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open(type)
			},
		},
		mounted() {
			this.form.token = uni.getStorageSync('token')
			this.form.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
			this.active4 = this.active3 + 1
			this.getData(this.form)
			this.form1.token = uni.getStorageSync('token')
			this.form1.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
			this.form2.token = uni.getStorageSync('token')
			this.form2.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
		},
		computed: {
			stage() {

			}
		}
	}
</script>

<style lang="scss">
	.active {
		color: #fc7c08;
		font-size: 40rpx;
		background-color: rgb(249, 249, 249);
	}

	.getPages {
		background-color: #fc7c08;
		color: #fff;
	}

	.bgc {
		background-color: #ffffff;
		cursor: pointer;
		transition: all 0.5s;
	}

	@mixin flex {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
	}

	@mixin height {
		/* #ifndef APP-NVUE */
		height: 100%;
		/* #endif */
		/* #ifdef APP-NVUE */
		flex: 1;
		/* #endif */
	}

	.box {
		@include flex;
	}

	.button {
		@include flex;
		align-items: center;
		justify-content: center;
		flex: 1;
		height: 35px;
		margin: 0 5px;
		border-radius: 5px;
	}

	.example-body {
		background-color: #fff;
		padding: 10px 0;
	}

	.button-text {
		color: #fff;
		font-size: 12px;
	}

	.popup-content {
		@include flex;
		align-items: center;
		justify-content: center;
		padding: 15px;
		height: 100px;
		background-color: #fff;
	}

	.popup-height {
		@include height;
		width: 200px;
	}

	.text {
		font-size: 12px;
		color: #333;
	}

	.popup-success {
		color: #fff;
		background-color: #e1f3d8;
	}

	.popup-warn {
		color: #fff;
		background-color: #faecd8;
	}

	.popup-error {
		color: #fff;
		background-color: #fde2e2;
	}

	.popup-info {
		color: #fff;
		background-color: #f2f6fc;
	}

	.success-text {
		color: #09bb07;
	}

	.warn-text {
		color: #e6a23c;
	}

	.error-text {
		color: #f56c6c;
	}

	.info-text {
		color: #909399;
	}

	.dialog,
	.share {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
	}

	.dialog-box {
		padding: 10px;
	}

	.dialog .button,
	.share .button {
		/* #ifndef APP-NVUE */
		width: 100%;
		/* #endif */
		margin: 0;
		margin-top: 10px;
		padding: 3px 0;
		flex: 1;
	}

	.dialog-text {
		font-size: 14px;
		color: #333;
	}
</style>